package cn.com.yxw.webapp.controller;

import cn.com.yxw.webapp.pojo.Admin;
import cn.com.yxw.webapp.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2015/4/9.
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private AdminService adminService;

     @RequestMapping("/login")
    public String loginPage(@ModelAttribute("admin") Admin admin, Model model){
//        model.addAttribute("admin", admin);
        return "login";
    }



    @RequestMapping("/showUserListIn")
    public String showUserListIn(ModelMap modelMap) {
        Admin admin = new Admin();
        admin.setUsername("sdfs");
        admin.setPassword("123");
        admin.setKey("345");
        Admin admin2 = new Admin();
        admin2.setUsername("sdfs");
        admin2.setPassword("123");
        admin2.setKey("345");
        List<Admin> list = new ArrayList<Admin>();
        list.add(admin);
        list.add(admin2);
        modelMap.addAttribute("list", list);
        return "userListXml";
    }

    @RequestMapping("/register")
    public String register(){

        return "register";
    }


}
